package com.biancheng.biancheng.biancheng6;

public class 卖鸭子递归算法 {

    public static int fun(int k,int i) {
        int l=0;
        int t=0;
        if(k<=7) {
            k++;
            i=(i+1)*2;
            l=9-k;
            t=i/2+1;
            System.out.println("经过第"+l+"个村子时卖出了"+t+"只鸭子");
            return fun(k,i);
        }
        else {
            return i;
        }
    }
    public static void main(String []args) {
        int sum=fun(1,2);
        System.out.println("出发时一共有"+sum+"只鸭子\n");
    }

}
